package com.gitee.ting723.upload.config;

import com.gitee.ting723.upload.service.ImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * file upload auto configuration
 *
 * @author zhanglianwei
 */
@Configuration
@EnableConfigurationProperties(FileUploadConfig.class)
@ConditionalOnClass(ImageService.class)
@ConditionalOnProperty(prefix = "file.upload", value = "enabled", matchIfMissing = true)
public class FileUploadAutoConfiguration {

    @Autowired
    private FileUploadConfig fileUploadConfig;

    @Bean
    @ConditionalOnMissingBean(ImageService.class)
    public ImageService imageService() {
        return new ImageService();
    }

}
